package com.fingard.dsp.bank.reqrespobj.elecbilltrans;

import com.fingard.dsp.bank.reqrespobj.ReqRespHeader;
import com.fingard.dsp.bank.reqrespobj.RetAtsBase;
import com.fingard.dsp.bank.reqrespobj.elecbilltrans.detail.RetAtsB102BillAccpSubmitDetail;
import com.fingard.text.StringHelper;
import com.fingard.xml.XmlTextWriter;

/**
 * Created by dell on 2017/10/1.
 */
public class RetAtsB102BillAccpSubmit extends RetAtsBase {
    public RetAtsB102BillAccpSubmit(ReqRespHeader p_header) {
        retHeader = p_header;
        retXmlWriter = new XmlTextWriter();//用于输出返回ATS的XML报文
    }

    public void writeBeforeDetail() {
        writeStart();
    }

    public void writeAfter() {
        writeEnd();
    }

    private boolean writtenBefore = false;

    public void writeDetail(RetAtsB102BillAccpSubmitDetail DB003Resp) {
        if (writtenBefore == false) {
            retXmlWriter.writeStartElement("DetailRecord");
            writtenBefore = true;
        }
        retXmlWriter.writeElementString("RespCode", DB003Resp.respCode);
        retXmlWriter.writeElementString("RespInfo", DB003Resp.respInfo);
        retXmlWriter.writeElementString("ReqSeqID", DB003Resp.reqSeqID);
        retXmlWriter.writeElementString("PayInfoCode", DB003Resp.payInfoCode);
        retXmlWriter.writeElementString("TransState", DB003Resp.transState);
        //用于电票日志文件名调整
        if(StringHelper.hasAnyChar(DB003Resp.reqSeqID)&&
                !DB003Resp.reqSeqID.equals(retHeader.reqSeqID)){
            retHeader.outTransID = DB003Resp.reqSeqID;
        }
    }
}
